package string;

public class StringDemo {

    public static void main(String[] args) {
        String s = "hello";
        String temp = s;
        s = "Hello";
        System.out.println(temp == s); //false, 说明改变字符串内容后，s引用已经指向了新对象。


        String s1 = "hello";
        String s2 = new String("hello");
        String s3 = new String("hello");

        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());
        System.out.println(s3.hashCode());

        System.out.println("-----------重写之前的hashCode-----------");
        System.out.println(System.identityHashCode(s1));
        System.out.println(System.identityHashCode(s2));
        System.out.println(System.identityHashCode(s3));


    }
}
